﻿using Linq;

var wordsNoUppercase = new string[]
{
    "jack", "castle", "tom"
};
Console.WriteLine(AnyWordUpperCase.IsAnyWordUpperCase(wordsNoUppercase));

var wordsWithUppercase = new string[]
{
    "jack", "castle", "FOX"
};

Console.WriteLine(AnyWordUpperCase.IsAnyWordUpperCase(wordsWithUppercase));

var numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 12, 34, 45, 67 };
var oddNumbers = numbers.Where(number => number % 2 == 1);
Console.WriteLine(oddNumbers);

// Any
bool isAnyLargerThan10 = numbers.Any(number => number > 10);
Console.WriteLine(isAnyLargerThan10);

// All
var areAllLargerThanZero = numbers.All(number => number > 0);
Console.WriteLine(areAllLargerThanZero);

// Count & LongCount
var countOddNumber = numbers.Count(number => number % 2 == 0);
var longCountOddNumber = numbers.LongCount(number => number % 2 == 0);

// Contains
var isContains = numbers.Contains(99);


// OrderBy 
var orderbyNumbers = numbers.OrderBy(number => number % 2 == 0);

// First & Last
var firstNumber = numbers.First(number => number > 10);
var lastNumber = numbers.Last(number => number < 50);

// Where
var whereNumbers = numbers.Where(number => number > 10);
foreach (var item in whereNumbers)
{
    Console.WriteLine(item);
}

// Distinct
var distinctNumber = numbers.Distinct();

// Select
var selectNumbers = numbers.Select(number => number * 2);


var listsOfNumbers = new List<List<int>>
{
    new List<int>{15,59,40,23,45,90,23},
    new List<int>{1,9,23,33,4,50,3,5,8,9,1},
    new List<int>{5,-9,10,-23,55,91,13},
};

var result = listsOfNumbers
    .Select(listsOfNumbers => new CountAndAverage
    {
        Count = listsOfNumbers.Count(),
        Average = listsOfNumbers.Average()
    })
    .OrderByDescending(countAndAverage => countAndAverage.Average)
    .Select(countAndAverage =>
        $"Count is:{countAndAverage.Count}, " +
        $"Average is:{countAndAverage.Average}");

Console.WriteLine(string.Join(Environment.NewLine,result));


Console.ReadKey();

public class CountAndAverage
{
    public int Count { get; init; }
    public double Average { get; init; }
}